<?php /*a:1:{s:70:"D:\phpstudy_pro\WWW\sact\application\admin\view\reimbursement\add.html";i:1622176447;}*/ ?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>add</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
</head>
<body>

  <div class="layui-form" style="padding: 20px 0 0 0;">
    <form id="formadd" method="post" action="">

    <div class="layui-form-item">
      <label class="layui-form-label">申请人</label>
      <div class="layui-input-inline">
        <input type="text" name="name" lay-verify="required" placeholder="请输入申请人名称" autocomplete="off" class="layui-input">
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label">性别</label>
      <div class="layui-input-block">
        <input type="radio" name="sex" value="1" title="男" checked="">
        <input type="radio" name="sex" value="2" title="女">
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label">摘要</label>
      <div class="layui-input-inline">
        <input type="text" name="content" lay-verify="required" placeholder="请输入报销摘要" autocomplete="off" class="layui-input">
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label">报销金额</label>
      <div class="layui-input-inline">
        <input type="text" name="money" lay-verify="number" placeholder="请输入报销金额" autocomplete="off" class="layui-input">
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label">处理状态</label>
      <div class="layui-input-block">
        <input type="radio" name="status" value="0" title="待处理" checked="">
        <input type="radio" name="status" value="1" title="已处理" disabled="true">
      </div>
    </div>

<!--      <div class="layui-form-item">-->
<!--        <label for="ment" class="layui-form-label">测试上传</label>-->
<!--        <div class="layui-input-block">-->
<!--          <input id="ment" name="reimbursement" type="file">-->
<!--        </div>-->
<!--      </div>-->

      <div class="layui-form-item">
        <input id="img" name="electronic_invoice" class="layui-input" type="hidden">
        <label for="L_pass" class="layui-form-label"><span class="x-red"></span>电子发票</label>
        <div class="layui-input-inline">
          <button type="button" class="layui-btn" id="test1"><i class="layui-icon">&#xe67c;</i>上传</button>
          <img class="layui-upload-img" id="demo1" height="38">
        </div>
      </div>

      <div class="layui-form-item">
        <input id="img2" name="reimbursement" class="layui-input" type="hidden">
        <label for="L_pass" class="layui-form-label"><span class="x-red"></span>报销单</label>
        <div class="layui-input-inline">
          <button type="button" class="layui-btn" id="test2"><i class="layui-icon">&#xe67c;</i>上传</button>
          <img class="layui-upload-img" id="demo2" height="38">
        </div>
      </div>

    <div class="layui-form-item">
      <div class="layui-input-block">
        <button class="layui-btn" lay-submit="" lay-filter="component-form-element">立即提交</button>
        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
      </div>
    </div>

    </form>
  </div>

  <script src="../../../layuiadmin/layui/layui.js"></script>
  <script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
  <script>
    layui.use(['form', 'layer', 'upload'], function () {
      $ = layui.jquery;
      form = layui.form;
      upload = layui.upload;
      layer = layui.layer;

      //电子发票上传
      var uploadInst = upload.render({
        elem: '#test1', //绑定上传id
        url: "<?php echo url('admin/Reimbursement/upload'); ?>", //上传接口
        before: function (obj) {
          obj.preview(function (index, file, result) {
            $('#demo1').attr('src', result); //图片链接（base64）
          });
        },
        done: function (res) {
          layer.msg(res.msg);
          if (res.code == 1) {
            $('#img').val(res.url);
          }
        },
        error: function () {
          var demoText = $('#demoText');
          demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
          demoText.find('.demo-reload').on('click', function () {
            uploadInst.upload();
          });
        }
      });

      //报销单上传
      var uploadInst = upload.render({
        elem: '#test2', //绑定上传id
        url: "<?php echo url('admin/Reimbursement/upload'); ?>", //上传接口
        before: function (obj) {
          obj.preview(function (index, file, result) {
            $('#demo2').attr('src', result); //图片链接（base64）
          });
        },
        done: function (res) {
          layer.msg(res.msg);
          if (res.code == 1) {
            $('#img2').val(res.url);
          }
        },
        error: function () {
          var demoText = $('#demoText');
          demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
          demoText.find('.demo-reload').on('click', function () {
            uploadInst.upload();
          });
        }
      });
    })


  $(function () {
    $("#formadd").submit(function (e) {
      e.preventDefault();
      var data = $(this).serialize();

      $.ajax({
        type: "post",
        url: "<?php echo url('admin/Reimbursement/addMent'); ?>",
        data: data,
        success: function (res) {
          if (res.code == 200) {
            layer.msg('添加成功', { icon: 6, time: 1000 }, function () {
              parent.location.reload();
            });
          } else {
            layer.msg('添加失败', { icon: 5, time: 1000 })
          }
        },
        error: function (res) {
        }
      });
    });
  });

  </script>
</body>
</html>